package com.itheima.execption;

import com.itheima.common.CustomException;
import com.itheima.domain.R;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.SQLIntegrityConstraintViolationException;

@ControllerAdvice
public class ExecptionEmployee {
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public R exc(Exception ex){
        return R.error("该用户已存在");
    }

    @ExceptionHandler(CustomException.class)
    @ResponseBody
    public R exceptionHandler(CustomException ex){
        return R.error(ex.getMessage());
    }
}
